package com.koron.order.cockpitStats.business.controller;


import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.cockpitStats.business.bean.query.DefectStatsQuery;
import com.koron.order.cockpitStats.business.bean.vo.DefectStatsGatherVo;
import com.koron.order.cockpitStats.business.bean.vo.OrderPassRateGatherVo;
import com.koron.order.cockpitStats.business.bean.vo.PlanStatsGatherVo;
import com.koron.order.cockpitStats.business.service.StatsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName StatsController
 * @description
 * @Author zhouj
 * @Date 2022/5/24 14:50
 */
@Api(tags = "驾驶舱统计(stats)")
@RestController
@RequestMapping("/stats/")
public class StatsController {

    @Autowired
    StatsService statsService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "查询缺陷统计")
    @GetMapping("queryDefectStats")
    public Response<DefectStatsGatherVo> queryDefectStats(DefectStatsQuery defectStatsQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), statsService, "queryDefectStats", DefectStatsGatherVo.class, defectStatsQuery));
    }

    @ApiOperation(value = "查询计划统计")
    @GetMapping("queryPlanStats")
    public Response<PlanStatsGatherVo> queryPlanStats(DefectStatsQuery defectStatsQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), statsService, "queryPlanStats", PlanStatsGatherVo.class, defectStatsQuery));
    }

    @ApiOperation(value = "查询工单合格率统计")
    @GetMapping("queryOrderPassRateStats")
    public Response<List<OrderPassRateGatherVo>> queryOrderPassRateStats(DefectStatsQuery defectStatsQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), statsService, "queryOrderPassRateStats", List.class, defectStatsQuery));
    }

}
